<div class="row">
	<div class="col-md-12">
		<form id="editForm" class="form-horizontal" action="${request.contextPath}/cms/ad/update" method="post" onsubmit="return false">
			<input type="hidden" id="id" name="id" value="${cmsAd.id}">
			<div class="box-body">
				<div class="form-group">
					<label id="adCategoryIdLabel" for="adCategoryId" class="col-sm-2  control-label">广告类目</label>
					<div class="col-sm-10">
						<select class="form-control" id="adCategoryId"  name="adCategoryId" style="width: 100%;" placeholder="选择广告类目...">
						</select>
					</div>
				</div>
				<div class="form-group">
					<label id="adNameLabel" for="adName" class="col-sm-2 control-label">名称</label>
					<div class="col-sm-4">
						<input type="text" class="form-control" name="name" id="adName"  value="${cmsAd.name}" placeholder="输入名称...">
					</div>
					<label id="adCodeLabel" for="adCode" class="col-sm-2 control-label">编码</label>
					<div class="col-sm-4">
						<input type="text" class="form-control" name="code" id="adCode"  value="${cmsAd.code}" placeholder="输入编码...">
					</div>
				</div>
				<div class="form-group">
					<label id="adDescriptionLabel" class="col-sm-2 control-label" >描述</label>
					<div class="col-sm-10">
						<input type="text" class="form-control" name="description" id="adDescription"  value="${cmsAd.description}" placeholder="输入描述...">
					</div>
				</div>
				<div class="form-group">
					<label id="adThumbnailLabel" for="adThumbnail" class="col-sm-2 control-label">缩略图</label>
					<div class="col-sm-7">
						<input type="text" class="form-control" name="thumbnail" id="adThumbnail"  value="${cmsAd.thumbnail}" placeholder="输入缩略图...">
					</div>
				</div>
				<div class="form-group">
					<label id="adBannerLabel" class="col-sm-2 control-label" >横幅图</label>
					<div class="col-sm-7">
						<input type="text" class="form-control" name="banner" id="adBanner"  value="${cmsAd.banner}" placeholder="输入横幅图...">
					</div>
				</div>
				<div class="form-group">
					<label id="adTargetLabel" for="adTarget" class="col-sm-2  control-label">打开方式</label>
					<div class="col-sm-4">
						<input type="text" class="form-control" name="target" value="${cmsAd.target}" id="adTarget"  placeholder="输入打开方式...">
					</div>
					<label id="adLinkUrlLabel" for="adLinkUrl" class="col-sm-2  control-label">链接地址</label>
					<div class="col-sm-4">
						<input type="text" class="form-control" name="linkUrl" value="${cmsAd.linkUrl}" id="adLinkUrl"  placeholder="输入链接地址...">
					</div>
				</div>
				<div class="form-group">
					<label id="adWhetherDeadlineLabel" for="adWhetherDeadline" class="col-sm-2 control-label">是否限期</label>
					<div class="col-sm-10">
						<select class="form-control" id="adWhetherDeadline"  name="whetherDeadline"  style="width: 100%;">
						</select>
					</div>
				</div>
				<div class="form-group">
					<label id="adStartTimeLabel" for="adStartTime" class="col-sm-2 control-label">开始时间</label>
					<div class="col-sm-4">
						<input id="adStartTime"  class="form-control pull-right" name="startTime"  value="${(cmsAd.startTime?string('yyyy/MM/dd HH:mm:ss'))!}"  type="text" placeholder="选择开始时间...">
					</div>
					<label id="adEndTimeLabel" for="adEndTime" class="col-sm-2 control-label">结束时间</label>
					<div class="col-sm-4">
						<input id="adEndTime"  class="form-control pull-right" name="endTime" type="text" value="${(cmsAd.endTime?string('yyyy/MM/dd HH:mm:ss'))!}" placeholder="选择结束时间...">
					</div>
				</div>
				<div class="form-group">
					<label id="adContentLabel" class="col-sm-2 control-label" >内容</label>
					<div class="col-sm-10">
							${cmsAd.content}
					</div>
				</div>
				<div class="form-group">
					<label id="adTypeLabel" for="adType" class="col-sm-2 control-label">类别</label>
					<div class="col-sm-2">
						<select class="form-control" id="adType"  name="type" style="width: 100%;">
						</select>
					</div>
					<label id="adWeightLabel" for="adWeight" class="col-sm-2  control-label">广告权重</label>
					<div class="col-sm-2">
						<input  class="form-control" name="weight" id="adWeight" type="number" value="${cmsAd.weight}"  placeholder="请输入...">
					</div>
					<label id="adStatusLabel" for="adStatus" class="col-sm-2  control-label">状态</label>
					<div class="col-sm-2">
						<select class="form-control" id="adStatus"  name="status" style="width: 100%;">
						</select>
					</div>
				</div>
				<div class="form-group">
					<label id="adRemarkLabel" class="col-sm-2 control-label">备注</label>
					<div class="col-sm-10">
						<input type="text" class="form-control" name="remark" id="adRemark" placeholder="输入备注...">
					</div>
				</div>
				<div class="error-message text-center" >
					<span class="error-icon"></span>
					<span id="error-msg" class="error-msg" ></span>
				</div>
			</div>
			<div class="box-footer">
				<div class="pull-right">
					<button type="button" class="btn btn-default btn-sm" data-dismiss="modal"><i class="fa fa-close"></i> 关闭</button>
				</div>
			</div>
		</form>
	</div>
</div>
<script type="text/javascript">

    $(function() {
        $("#adStatus").select2({
            data: StatusStore,
            theme: "bootstrap",
            minimumResultsForSearch: Infinity
        }).val('${cmsAd.status}').trigger("change");
        $("#adType").select2({
            data: AdTypeStore,
            theme: "bootstrap",
            minimumResultsForSearch: Infinity
        }).val('${cmsAd.type}').trigger("change");

        var $adWhetherDeadline = $("#adWhetherDeadline");
        $adWhetherDeadline.select2({
            data: WhetherStore,
            theme: "bootstrap",
            minimumResultsForSearch: Infinity
        }).val('${cmsAd.whetherDeadline}').trigger("change");


		$.ajax({
			type:"get",
			url:'/cms/ad/category/list',
			dataType:'json'
		}).done(function(result){
			var o = [];
			var a = result;
			$.each(a, function() {
				if(this.id !== undefined && this.id !==''){
					o.push({'id':this.id,'text':this.name});
				}
			});
			$("#adCategoryId").select2({
				data:o,
				placeholder: "广告类目...",
				allowClear: true,
				language: "zh-CN",
				theme: "bootstrap"
			}).val('${cmsAd.adCategoryId}').trigger("change");
		});


	});
</script>